package test;

import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.net.ServerSocket;
import java.net.Socket;

import remote_work.dto.InputObject;
import remote_work.dto.OutputObject;

/**
 * @author LiuPing
 *
 * 2018年3月21日
 */
public class Server {

	public static void main(String[] args) throws Exception {
		ServerSocket ss = new ServerSocket(8080);
		while (true) {
			Socket s = ss.accept();
			new Runnable() {
				@Override
				public void run() {
					try {
						ObjectInputStream ois = new ObjectInputStream(s.getInputStream());
						InputObject io = (InputObject)ois.readObject();
						System.out.println(io.getMethod());
						OutputObject oo = new OutputObject();
						oo.setReturnMessage("收到了");
						ObjectOutputStream oos = new ObjectOutputStream(s.getOutputStream());
						oos.writeObject(oo);
						oos.flush();
					} catch (Exception e) {
						e.printStackTrace();
					}
				}
			}.run();
		}
	}
}
